//
//  MJRefreshCircleHeader.m
//  Footer
//
//  Created by leotao on 16/12/20.
//  Copyright © 2016年 leotao. All rights reserved.
//

#import "MJRefreshCircleHeader.h"
#import "CircleView.h"
#import "Masonry.h"

@interface MJRefreshCircleHeader ()

@property (strong, nonatomic) CircleView *circleView;

@end

@implementation MJRefreshCircleHeader

- (void)prepare
{
    [super prepare];
    
    self.circleView = [[CircleView alloc] init];
    [self addSubview:self.circleView];
    
    [self.circleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
}

- (void)placeSubviews
{
    [super placeSubviews];
    
    
}

- (void)setState:(MJRefreshState)state
{
    MJRefreshCheckState
    
    if (state == MJRefreshStateRefreshing) {
        [self.circleView startAnimating];
    } else if (state == MJRefreshStateIdle) {
        if (oldState == MJRefreshStateRefreshing) {
            [self.circleView endAnimating];
        }
    }
}

- (void)setPullingPercent:(CGFloat)pullingPercent
{
    [super setPullingPercent:pullingPercent];
    
    self.circleView.progress = pullingPercent;
}

@end
